<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Estampillas extends MY_Controller {
    
    public function index(){
        $data ['titulo']= 'SysCoop';
        $data ['subtitulo']='Estampillas';
       
	$data['estampillas'] = $this->Estampillas_model->listar_por_valores();
			
	$datoPrincipal ['contenidoPrincipal'] = $this->load->view('estampillas/cobro_estampillas', $data, TRUE);
        $this->load->view('templates',$datoPrincipal);
    }
    
    public function registrar(){
                $data ['titulo']= 'SysCoop';
                $data['subtitulo']='Estampillas';
		
                // set validation properties
		$this->_set_rules();
                
                $estampillas = $this->Estampillas_model->listar_por_valores();
                
                foreach ($estampillas as $estampilla){
                    $id= $estampilla->Est_Id;
                    $cant = $this->input->post('$estampilla->Est_Id');
                                
                    $venta = $this->Estampillas_model->insert($id,$cant);
                    if ($venta=null){
                        $data['message']='Error, no guardado.';
                    }else{
                        $data['message']='Exito.';
                    }
                }                
		
                $datoPrincipal ['contenidoPrincipal'] = $this->load->view('success', $data, TRUE);
                $this->load->view('templates',$datoPrincipal);        
    }
    
    function _set_rules(){
        $this->form_validation->set_rules('cant', 'Cantidad', 'required');
    }
    
}

?>
